from django.db import models

# Create your models here.
class Tag(models.Model):
    Tag = models.CharField(max_length=20)
    def __str__(self):
        return self.Tag
    class Meta:
        db_table = '标签'
        verbose_name = '标签'
        verbose_name_plural = '标签'
class Category(models.Model):
    Category = models.CharField(max_length=20)
    def __str__(self):
        return self.Category
    class Meta:
        db_table = '分类'
        verbose_name = '分类'
        verbose_name_plural = '分类'
class Post(models.Model):
    title = models.CharField(max_length=20)
    content = models.TextField()
    imagePath = models.ImageField(upload_to='img')
    category = models.ForeignKey(Category,on_delete=models.CASCADE)
    tags = models.ManyToManyField(Tag)
    def __str__(self):
        return self.title
    class Meta:
        db_table = '文章'
        verbose_name = '文章'
        verbose_name_plural = '文章'

